package com.maiji.cloud.mapper;

import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.maiji.cloud.entities.shopingmall.ExchangeLog;

@Mapper
public interface ExchangeLogMapper extends BaseMapper<ExchangeLog> {

	/**
	 * 分頁查詢兑换记录
	 * @param userId
	 * @param start
	 * @param limit
	 * @return
	 */
	List<ExchangeLog> selectListByUserId(@Param("userId")String userId,@Param("type")Integer type, @Param("start")Integer start,@Param("limit")Integer limit);
	
	/**
	 * 根据优惠券id和用户id查看免费优惠券
	 * @param userId
	 * @param discountCouponId
	 * @return
	 */
	List<ExchangeLog> selectListByUserId(@Param("userId")String userId,@Param("discountCouponId")String discountCouponId);
	
	

	/**
	 *  可用优惠券
	 * @param userId
	 * @param type 免费领取，积分兑换
	 * @return
	 */
	List<ExchangeLog> getUsableDiscountCouponList(@Param("nowTime")Date nowTime,@Param("price")Double price,@Param("userId")String userId,@Param("type")Integer type);
	
	/**
	 *   筛选出符合价格并且当前时间点可用的的优惠券
	 * @param userId
	 * @param type 免费领取，积分兑换
	 * @return
	 */
	List<ExchangeLog> getUsableDiscountCouponListByTime(@Param("nowTime")Date nowTime,@Param("price")Double price,@Param("userId")String userId,@Param("type")Integer type);
	
	/**
	 * 获取用户已经领取过的优惠券id集合
	 * @param price
	 * @param userId
	 * @param type
	 * @return
	 */
	List<String> getDiscountCouponList(@Param("nowTime")Date nowTime,@Param("price")Double price,@Param("userId")String userId,@Param("type")Integer type);
	
	/**
	 * 
	 * @param exchangeLog
	 */
    Integer insertOne(ExchangeLog exchangeLog);
    
    /**
	 * 1：未使用，2：已使用：3：已过期优惠券列表
	 * @param param
	 * @param maijiToken
	 * @return
	 */
    List<ExchangeLog> getHaveDiscountCouponList(@Param("nowTime")Date nowTime,@Param("userId")String userId,@Param("param") Integer param,@Param("start")Integer start,@Param("limit")Integer limit);

}
